import { BasicColumn, FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
export const columns: BasicColumn[] = [
  {
    title: '房间号',
    dataIndex: 'room',
    align: 'center',
    width: 120,
  },
  {
    title: '少于多少充值',
    dataIndex: 'lessNumber',
    align: 'center',
    width: 120,
  },
  {
    title: '每次充电度数',
    dataIndex: 'number',
    align: 'center',
    width: 180,
  },
  {
    title: '备注',
    dataIndex: 'remark',
    align: 'center',
    width: 120,
  },
  {
    title: '状态',
    dataIndex: 'status',
    align: 'center',
    width: 120,
    customRender: ({ text }) => {
      return h(Tag, { color: text == 1 ? 'green' : text == 0 ? 'gray' : 'gray' }, () => (text == 1 ? '自动充电' : text == 0 ? '不充电' : '--'));
    },
  },
  {
    title: '录入时间',
    dataIndex: 'addtime',
    align: 'center',
    width: 120,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'room',
    label: '房间号',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'status',
    label: '类型',
    component: 'RadioButtonGroup',
    componentProps: {
      //options里面由一个一个的radio组成,支持disabled禁用
      options: [
        { label: '自动充电', value: 1 },
        { label: '不充电', value: 0 },
      ],
    },
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '自动充电房间表',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '房间号',
    field: 'room',
    component: 'Input',
  },
  {
    label: '少于多少充值',
    field: 'lessNumber',
    component: 'Input',
  },
  {
    label: '每次充电度数',
    field: 'number',
    component: 'Input',
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '类型',
    field: 'status',
    component: 'RadioButtonGroup',
    componentProps: {
      options: [
        { label: '自动充电', value: 1 },
        { label: '不充电', value: 0 },
      ],
    },
  },
];
